using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DTO;
using BUS;
using Utility;

public partial class Doanhnghiep_ThongKe_DN : System.Web.UI.Page
{
    float tongdt = 0;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadData();
        }
    }

    private void LoadData()
    {
        int id = int.Parse(Request.QueryString["id"]);
        Criteria c = new Criteria();
        if (txt_tensp.Text != "")
        {
            c.add(Condition.AND, tbSanPhamColumns.tensp, Condition.LIKE, txt_tensp.Text);
        }
        c.add(Condition.AND, tbSanPhamColumns.doanhnghiep, Condition.EQUAL, id);
        int total = 0;
        tbSanPhamCollection sanphamCollection = tbSanPhamBUS.Get(c.Criter, Pager.CurrentIndex, Pager.PageSize, tbSanPhamColumns.masp.ToString(), OrderDirection.ASC.ToString(), out total);
        Repeater1.DataSource = sanphamCollection;
        Repeater1.DataBind();
        Pager.ItemCount = total;
    }
   
    protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem ||
           e.Item.ItemType == ListItemType.Item)
        {
            tbSanPham sp = (tbSanPham)e.Item.DataItem;
            Literal lit_tensp = (Literal)e.Item.FindControl("lit_tensp");
            Literal lit_tongvon = (Literal)e.Item.FindControl("lit_tongvon");
            Literal lit_doanhthu = (Literal)e.Item.FindControl("lit_doanhthu");
            lit_tensp.Text = sp.tensp;
            float tongvon = sp.giaban * sp.soluongban;
            lit_tongvon.Text  = tongvon.ToString();
            float dt = sp.giaban *sp.damua ;
            lit_doanhthu.Text  = dt.ToString();
            tongdt = tongdt + dt;
        }
        Label2.Text = tongdt.ToString();
    }
    protected void btn_Search_Click(object sender, EventArgs e)
    {
        LoadData();
    }
}
